using System;
using System.Collections.Generic;
using System.Linq;

namespace Cassandraemon
{
	public class ByteArrayEqualityComparer : EqualityComparer<byte[]>
	{
		public override bool Equals (byte[] x, byte[] y)
		{
			if(x == null || y == null) return false;
			
			return x.SequenceEqual(y);
		}
		
		public override int GetHashCode (byte[] obj)
		{
			if(obj == null) throw new ArgumentNullException("obj");
			
			int sum = 0;
			
			foreach(var b in obj)
			{
				sum = 33 * sum + b;
			}
			
			return sum;
		}
	}
}

